<?php
/*
*+---------------------------------------+
*|                                       |
*|           By mlboy@126.com            |
*|       Copyright (C) 2015  mlboy       |
*|          All rights reserved          |
*|            www.maliang.xyz            |
*|                                       |
*+---------------------------------------+
*/
class AdminModel extends Eloquent {
    protected $table = 'admin';
    protected $hidden = array('password');
    public function getGroup(){
        return $this->belongsToMany('AdminGroup', 'admin_group_access', 'uid', 'group_id');
    }
    public function getRule(){
        $rules = array();
        $rules_arr=array();
        foreach($this->getGroup as $v){
            $rules_arr = array_merge($rules_arr,explode(',',$v->rules));
        }

        $rules = AdminRule::whereIn('id',$rules_arr)->get();
        return $rules;
    }
}
